home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / DriverGestalt.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  16KB  |  403 lines

  1. /*
  2.      File:        DriverGestalt.h
  3.  
  4.      Contains:    Driver Gestalt interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __DRIVERGESTALT__
  19. #define __DRIVERGESTALT__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __OSUTILS__
  25. #include <OSUtils.h>
  26. #endif
  27. #ifndef __SCSI__
  28. #include <SCSI.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT_SUPPORTED
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #if FOR_SYSTEM7_ONLY
  44. /*__________________________________________________________________________________*/
  45. /* The Driver Gestalt bit in the dCtlFlags */
  46.  
  47. enum {
  48.     kbDriverGestaltEnable        = 2,
  49.     kmDriverGestaltEnableMask    = (1 << kbDriverGestaltEnable)
  50. };
  51.  
  52. /*__________________________________________________________________________________*/
  53. /* Driver Gestalt related csCodes */
  54.  
  55. enum {
  56.     kDriverGestaltCode            = 43,                            /* various uses */
  57.     kDriverConfigureCode        = 43,                            /* various uses */
  58.     kdgLowPowerMode                = 70,                            /* Sets/Returns the current energy consumption level */
  59.     kdgReturnDeviceID            = 120,                            /* returns SCSI DevID in csParam[0] */
  60.     kdgGetCDDeviceInfo            = 121                            /* returns CDDeviceCharacteristics in csParam[0] */
  61. };
  62.  
  63. /*__________________________________________________________________________________*/
  64. /* Driver Gestalt selectors */
  65.  
  66. enum {
  67.     kdgVersion                    = 'vers',                        /* Version number of the driver in standard Apple format */
  68.     kdgDeviceType                = 'devt',                        /* The type of device the driver is driving. */
  69.     kdgInterface                = 'intf',                        /* The underlying interface that the driver is using (if any) */
  70.     kdgSync                        = 'sync',                        /* True if driver only behaves synchronously. */
  71.     kdgBoot                        = 'boot',                        /* value to place in PRAM for this drive (long) */
  72.     kdgWide                        = 'wide',                        /* True if driver supports ioWPosOffset */
  73.     kdgPurge                    = 'purg',                        /* Driver purge permission (True = purge; False = no purge) */
  74.     kdgSupportsSwitching        = 'lpwr',                        /* True if driver supports power switching */
  75.     kdgMin3VPower                = 'pmn3',                        /* Minimum 3.3V power consumption in microWatts */
  76.     kdgMin5VPower                = 'pmn5',                        /* Minimum 5V power consumption in microWatts */
  77.     kdgMax3VPower                = 'pmx3',                        /* Maximum 3.3V power consumption in microWatts */
  78.     kdgMax5VPower                = 'pmx5',                        /* Maximum 5V power consumption in microWatts */
  79.     kdgInHighPower                = 'psta',                        /* True if device is currently in high power mode */
  80.     kdgSupportsPowerCtl            = 'psup',                        /* True if driver supports following five calls */
  81.     kdgAPI                        = 'dAPI',                        /* API support for PC Exchange */
  82.     kdgEject                    = 'ejec'                        /* Eject options for shutdown/restart <2/03/95> */
  83. };
  84.  
  85. /*__________________________________________________________________________________*/
  86. /* status parameter block for Driver Gestalt calls */
  87. struct DriverGestaltParam {
  88.     QElemPtr                         qLink;
  89.     short                             qType;
  90.     short                             ioTrap;
  91.     Ptr                             ioCmdAddr;
  92.     ProcPtr                         ioCompletion;
  93.     OSErr                             ioResult;
  94.     StringPtr                         ioNamePtr;
  95.     short                             ioVRefNum;
  96.     short                             ioCRefNum;                    /* refNum for I/O operation */
  97.     short                             csCode;                        /*    == kDriverGestaltCode */
  98.     OSType                             driverGestaltSelector;        /* 'sync', 'vers', etc. */
  99.     UInt32                             driverGestaltResponse;        /* Could be a pointer, bit field or other format */
  100.     UInt32                             driverGestaltResponse1;        /* Could be a pointer, bit field or other format */
  101.     UInt32                             driverGestaltResponse2;        /* Could be a pointer, bit field or other format */
  102.     UInt32                             driverGestaltResponse3;        /* Could be a pointer, bit field or other format */
  103.     UInt16                             driverGestaltfiller;        /* To pad out to the size of a controlPB */
  104. };
  105. typedef struct DriverGestaltParam DriverGestaltParam;
  106.  
  107. /*
  108.  Note that the various response definitions are overlays of the response fields above.
  109.    For instance the deviceType response would be returned in driverGestaltResponse.
  110.    The DriverGestaltPurgeResponse would be in driverGestaltResponse and driverGestaltResponse1
  111. */
  112. /* GetDriverGestaltDevTResponse(gestaltPtr)->deviceType */
  113. #define GetDriverGestaltDevTResponse(p) ((DriverGestaltDevTResponse *)(&((p)->driverGestaltResponse)))
  114. #define GetDriverGestaltIntfResponse(p) ((DriverGestaltIntfResponse *)(&((p)->driverGestaltResponse)))
  115. #define GetDriverGestaltPowerResponse(p) ((DriverGestaltPowerResponse *)(&((p)->driverGestaltResponse)))
  116. #define GetDriverGestaltSyncResponse(p) ((DriverGestaltSyncResponse *)(&((p)->driverGestaltResponse)))
  117. #define GetDriverGestaltBootResponse(p) ((DriverGestaltBootResponse *)(&((p)->driverGestaltResponse)))
  118. #define GetDriverGestaltBootResponse(p) ((DriverGestaltBootResponse *)(&((p)->driverGestaltResponse)))
  119. #define GetDriverGestaltPurgeResponse(p) ((DriverGestaltPurgeResponse *)(&((p)->driverGestaltResponse)))
  120. #define GetDriverGestaltEjectResponse(p) ((DriverGestaltEjectResponse *)(&((p)->driverGestaltResponse)))
  121. #define GetDriverGestaltVersionResponse(p) (((NumVersion*)(&((p)->driverGestaltResponse))))
  122. #define GetDriverGestaltAPIResponse(p) ((DriverGestaltAPIResponse *)(&((p)->driverGestaltResponse)))
  123. #define GetDriverGestaltBooleanResponse(p) ((Boolean *)(&((p)->driverGestaltResponse)))
  124. /*__________________________________________________________________________________*/
  125. /* Device Types response */
  126. struct DriverGestaltDevTResponse {
  127.     OSType                             deviceType;
  128. };
  129. typedef struct DriverGestaltDevTResponse DriverGestaltDevTResponse;
  130.  
  131.  
  132. enum {
  133.     kdgDiskType                    = 'disk',                        /* standard r/w disk drive */
  134.     kdgTapeType                    = 'tape',                        /* tape drive */
  135.     kdgPrinterType                = 'prnt',                        /* printer */
  136.     kdgProcessorType            = 'proc',                        /* processor */
  137.     kdgWormType                    = 'worm',                        /* write-once */
  138.     kdgCDType                    = 'cdrm',                        /* cd-rom drive */
  139.     kdgFloppyType                = 'flop',                        /* floppy disk drive */
  140.     kdgScannerType                = 'scan',                        /* scanner */
  141.     kdgFileType                    = 'file',                        /* Logical Partition type based on a file (Drive Container) */
  142.     kdgRemovableType            = 'rdsk'                        /* A removable media hard disk drive ie. Syquest, Bernioulli */
  143. };
  144.  
  145. /*__________________________________________________________________________________*/
  146. /* Device Interfaces response */
  147. struct DriverGestaltIntfResponse {
  148.     OSType                             interfaceType;
  149. };
  150. typedef struct DriverGestaltIntfResponse DriverGestaltIntfResponse;
  151.  
  152.  
  153. enum {
  154.     kdgScsiIntf                    = 'scsi',
  155.     kdgPcmciaIntf                = 'pcmc',
  156.     kdgATAIntf                    = 'ata ',
  157.     kdgFireWireIntf                = 'fire',
  158.     kdgExtBus                    = 'card'
  159. };
  160.  
  161. /*__________________________________________________________________________________*/
  162. /* Power Saving */
  163. struct DriverGestaltPowerResponse {
  164.     unsigned long                     powerValue;                    /* Power consumed in µWatts */
  165. };
  166. typedef struct DriverGestaltPowerResponse DriverGestaltPowerResponse;
  167.  
  168. /*__________________________________________________________________________________*/
  169. /* Disk Specific */
  170. struct DriverGestaltSyncResponse {
  171.     Boolean                         behavesSynchronously;
  172.     UInt8                             pad[3];
  173. };
  174. typedef struct DriverGestaltSyncResponse DriverGestaltSyncResponse;
  175.  
  176. struct DriverGestaltBootResponse {
  177.     UInt8                             extDev;                        /*  Packed target (upper 5 bits) LUN (lower 3 bits) */
  178.     UInt8                             partition;                    /*  Unused */
  179.     UInt8                             SIMSlot;                    /*  Slot */
  180.     UInt8                             SIMsRSRC;                    /*  sRsrcID */
  181. };
  182. typedef struct DriverGestaltBootResponse DriverGestaltBootResponse;
  183.  
  184. struct DriverGestaltAPIResponse {
  185.     short                             partitionCmds;                /* if bit 0 is nonzero, supports partition control and status calls */
  186.                                                                 /*         prohibitMounting (control, kProhibitMounting) */
  187.                                                                 /*         partitionToVRef (status, kGetPartitionStatus) */
  188.                                                                 /*         getPartitionInfo (status, kGetPartInfo) */
  189.     short                             unused1;                    /* all the unused fields should be zero */
  190.     short                             unused2;
  191.     short                             unused3;
  192.     short                             unused4;
  193.     short                             unused5;
  194.     short                             unused6;
  195.     short                             unused7;
  196.     short                             unused8;
  197.     short                             unused9;
  198.     short                             unused10;
  199. };
  200. typedef struct DriverGestaltAPIResponse DriverGestaltAPIResponse;
  201.  
  202. /* Flags for purge permissions */
  203.  
  204. enum {
  205.     kbCloseOk                    = 0,                            /* Ok to call Close */
  206.     kbRemoveOk                    = 1,                            /* Ok to call RemoveDrvr */
  207.     kbPurgeOk                    = 2,                            /* Ok to call DisposePtr */
  208.     kmNoCloseNoPurge            = 0,
  209.     kmOkCloseNoPurge            = (1 << kbCloseOk) + (1 << kbRemoveOk),
  210.     kmOkCloseOkPurge            = (1 << kbCloseOk) + (1 << kbRemoveOk) + (1 << kbPurgeOk)
  211. };
  212.  
  213. /* Driver purge permission structure */
  214. struct DriverGestaltPurgeResponse {
  215.     UInt16                             purgePermission;            /* 0 = Do not change the state of the driver */
  216.                                                                 /* 3 = Do Close() and DrvrRemove() this driver */
  217.                                                                 /* but don't deallocate driver code */
  218.                                                                 /* 7 = Do Close(), DrvrRemove(), and DisposePtr() */
  219.     UInt16                             purgeReserved;
  220.     Ptr                             purgeDriverPointer;            /* pointer to the start of the driver block (valid */
  221.                                                                 /* only of DisposePtr permission is given */
  222. };
  223. typedef struct DriverGestaltPurgeResponse DriverGestaltPurgeResponse;
  224.  
  225. struct DriverGestaltEjectResponse {
  226.     UInt32                             ejectFeatures;                /*  */
  227. };
  228. typedef struct DriverGestaltEjectResponse DriverGestaltEjectResponse;
  229.  
  230. /* Flags for Ejection Features field */
  231.  
  232. enum {
  233.     kRestartDontEject            = 0,                            /* Dont Want eject during Restart */
  234.     kShutDownDontEject            = 1,                            /* Dont Want eject during Shutdown */
  235.     kRestartDontEject_Mask        = 1 << kRestartDontEject,
  236.     kShutDownDontEject_Mask        = 1 << kShutDownDontEject
  237. };
  238.  
  239. /*__________________________________________________________________________________*/
  240. /* CD-ROM Specific */
  241. /*
  242.  The CDDeviceCharacteristics result is returned in csParam[0] and csParam[1] of a 
  243.    standard CntrlParam parameter block called with csCode kdgGetCDDeviceInfo.
  244. */
  245. struct CDDeviceCharacteristics {
  246.     UInt8                             speedMajor;                    /* High byte of fixed point number containing drive speed */
  247.     UInt8                             speedMinor;                    /* Low byte of "" CD 300 == 2.2, CD_SC == 1.0 etc. */
  248.     UInt16                             cdFeatures;                    /* Flags field for features and transport type of this CD-ROM */
  249. };
  250. typedef struct CDDeviceCharacteristics CDDeviceCharacteristics;
  251.  
  252.  
  253. enum {
  254.     cdFeatureFlagsMask            = 0xFFFC,                        /* The Flags are in the first 14 bits of the cdFeatures field */
  255.     cdTransportMask                = 0x0003                        /* The transport type is in the last 2 bits of the cdFeatures field */
  256. };
  257.  
  258. /* Flags for CD Features field */
  259.  
  260. enum {
  261.     cdMute                        = 0,                            /* The following flags have the same bit number */
  262.     cdLeftToChannel                = 1,                            /* as the Audio Mode they represent.  Don't change */
  263.     cdRightToChannel            = 2,                            /* them without changing dControl.c */
  264.     cdLeftPlusRight                = 3,                            /* Reserve some space for new audio mixing features (4-7) */
  265.     cdSCSI_2                    = 8,                            /* Supports SCSI2 CD Command Set */
  266.     cdStereoVolume                = 9,                            /* Can support two different volumes (1 on each channel) */
  267.     cdDisconnect                = 10,                            /* Drive supports disconnect/reconnect */
  268.     cdWriteOnce                    = 11,                            /* Drive is a write/once (CD-R?) type drive */
  269.     cdMute_Mask                    = 1 << cdMute,
  270.     cdLeftToChannel_Mask        = 1 << cdLeftToChannel,
  271.     cdRightToChannel_Mask        = 1 << cdRightToChannel,
  272.     cdLeftPlusRight_Mask        = 1 << cdLeftPlusRight,
  273.     cdSCSI_2_Mask                = 1 << cdSCSI_2,
  274.     cdStereoVolume_Mask            = 1 << cdStereoVolume,
  275.     cdDisconnect_Mask            = 1 << cdDisconnect,
  276.     cdWriteOnce_Mask            = 1 << cdWriteOnce
  277. };
  278.  
  279. /* Transport types */
  280.  
  281. enum {
  282.     cdCaddy                        = 0,                            /* CD_SC,CD_SC_PLUS,CD-300 etc. */
  283.     cdTray                        = 1,                            /* CD_300_PLUS etc. */
  284.     cdLid                        = 2                                /* Power CD - eg no eject mechanism */
  285. };
  286.  
  287. /*
  288.  the following are used by PC Exchange (and houdini)
  289.  Control Codes
  290. */
  291.  
  292. enum {
  293.     kRegisterPartition            = 50,                            /* PCX needs a new Drive (for a non-macintosh partition found on the disk)*/
  294.     OLD_REGISTER_PARTITION        = 301,                            /* left in for compatibility with shipping Houdini*/
  295.     THE_DRIVE                    = 0,                            /* DrvQElPtr for the partition to register*/
  296.     THE_PHYS_START                = 1,                            /* The start of the partition in logical blocks*/
  297.     THE_PHYS_SIZE                = 2,                            /* The size of the partition in logical blocks*/
  298.     kGetADrive                    = 51,                            /* control call to ask the driver to create a drive*/
  299.     OLD_GET_A_DRIVE                = 302,                            /* left in for compatibility with shipping Houdini*/
  300.     THE_VAR_QUEL                = 0,                            /* a VAR parameter for the returned DrvQElPtr*/
  301.     kProhibitMounting            = 52,                            /* Dont allow mounting of the following drives*/
  302.     kOldProhibitMounting        = 2100,                            /* left in for compatibility with shipping Houdini*/
  303.     kProhibitDevice                = 0,                            /* CS Param 0 and 1 (partInfoRecPtr)*/
  304.     kIsContainerMounted            = 53,
  305.     kOldIsContainerMounted        = 2201,                            /* left in for compatibility with shipping Houdini            */
  306.     kContainerVRef                = 0,                            /* CS Param 0 and 1 (VRefNum)*/
  307.     kContainerParID                = 1,                            /* CS Param 2 and 3 (Parent ID)*/
  308.     kContainerName                = 2,                            /* CS Param 4 and 5 (File Name)*/
  309.     kContainerResponse            = 3,                            /* CS Param 6 and 7 (VAR pointer to short result)*/
  310.     kMountVolumeImg                = 54,
  311.     OLD_MOUNT_VOLUME_IMG        = 2000,
  312.     MV_HOST_VREFNUM                = 0,
  313.     MV_HOST_PAR_ID                = 1,
  314.     MV_HOST_NAME                = 2,
  315.     MV_REQ_PERM                    = 3
  316. };
  317.  
  318. /* Status Codes*/
  319.  
  320. enum {
  321.     kGetPartitionStatus            = 50,                            /* what is the status of this partition?*/
  322.     kOldGetPartitionStatus        = 2200,                            /* left in for compatibility with shipping Houdini*/
  323.     kDeviceToQuery                = 0,                            /* CS Param 0 and 1 (partInfoRecPtr)*/
  324.     kDeviceResponse                = 1,                            /* CS Param 2 and 3 (VAR pointer to short result)*/
  325.     kGetPartInfo                = 51,                            /* Get a partition info record based on the provided vrefnum*/
  326.     kOldGetPartInfo                = 2300,                            /* left in for compatibility with shipping Houdini*/
  327.     kPartInfoResponse            = 0,                            /* var parameter (pointer to partInfoRec) CSParam [0-1]*/
  328.     kGetContainerAlias            = 52,                            /* Get the alias that describes the file this drive was mounted from.*/
  329.     kOldGetContainerAlias        = 2400,                            /* left in for compatibility with shipping Houdini*/
  330.     kGetAliasResponse            = 0                                /*    var parameter (pointer to a Handle) CSParam [0-1]*/
  331. };
  332.  
  333. /* the result codes to come from the driver interface */
  334.  
  335. enum {
  336.     DRIVER_NOT_INSTALLED        = -1,
  337.     DRIVER_BUSY                    = -2,
  338.     CANT_MOUNT_WITHIN_THIS_FS    = -3,                            /* can only mount container within residing on HFS volume*/
  339.     VOLUME_ALREADY_MOUNTED        = -4                            /* Already Mounted*/
  340. };
  341.  
  342. /* requisite structures for PCX control and status calls*/
  343.  
  344. enum {
  345.     kMaxProhibted                = 2                                /* the max number of volumes the PC can possibly have mounted*/
  346. };
  347.  
  348. /* GestaltSelector for Finding Driver information*/
  349.  
  350. enum {
  351.     kGetDriverInfo                = 'vdrc'
  352. };
  353.  
  354.  
  355. enum {
  356.     VerifyCmd                    = 5,
  357.     FormatCmd                    = 6,
  358.     EjectCmd                    = 7
  359. };
  360.  
  361. /* Partition information passed back and forth between PCX and the driver*/
  362. struct partInfoRec {
  363.     DeviceIdent                     SCSIID;                        /* DeviceIdent for the device*/
  364.     UInt32                             physPartitionLoc;            /* physical block number of beginning of partition*/
  365.     UInt32                             partitionNumber;            /* the partition number of this partition*/
  366. };
  367. typedef struct partInfoRec partInfoRec;
  368.  
  369. typedef partInfoRec *partInfoRecPtr;
  370. struct vPartInfoRec {
  371.     UInt8                             VPRTVers;                    /* Virtual partition version number*/
  372.     UInt8                             VPRTType;                    /* virtual partition type (DOS, HFS, etc)*/
  373.     SInt16                             drvrRefNum;                    /* Driver Reference number of partition driver*/
  374. };
  375. typedef struct vPartInfoRec vPartInfoRec;
  376.  
  377. typedef vPartInfoRec *vPartInfoRecPtr;
  378. /* Information related to DOS partitions*/
  379.  
  380. enum {
  381.     kDOSSigLow                    = 0x01FE,                        /* offset into boot block for DOS signature*/
  382.     kDOSSigHi                    = 0x01FF,                        /* offset into boot block for DOS signature*/
  383.     kDOSSigValLo                = 0x55,                            /* DOS signature value in low byte*/
  384.     kDOSSigValHi                = 0xAA                            /* DOS signature value in high byte*/
  385. };
  386.  
  387. #endif
  388.  
  389. #if PRAGMA_ALIGN_SUPPORTED
  390. #pragma options align=reset
  391. #endif
  392.  
  393. #if PRAGMA_IMPORT_SUPPORTED
  394. #pragma import off
  395. #endif
  396.  
  397. #ifdef __cplusplus
  398. }
  399. #endif
  400.  
  401. #endif /* __DRIVERGESTALT__ */
  402.  
  403.